/* eslint valid-jsdoc: "off" */

'use strict';
const path = require("path");

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
    /**
     * built-in config
     * @type {Egg.EggAppConfig}
     **/
    const config = exports = {};
    config.wxKey = {
        appid: `wx81b937195945b472`,
        apps: `7cc1cb020a47a94b3a20e25054de498f`
    }

    // use for cookie sign key, should change to your own and keep security
    config.keys = appInfo.name + '_1619329601832_2739';
    config.jwt = {
        secret: "165165",
        expiresIn: '24h',
    };
    config.security = {
        xframe: {
            enable: false,
        },
        csrf: {
            enable: false,
            // headerName: 'x-csrf-token',// 自定义请求头
        }
    };
    // add your middleware config here
    config.middleware = ["response"];
    config.cors = {
        origin: '*',
        allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS'
    };
    config.static = {
        prefix: '/',
        dir: [path.join(appInfo.baseDir, 'app/public'), path.join(appInfo.baseDir, 'app/pages')],
        dynamic: true,
        preload: false,
        buffer: false,
        maxFiles: 1000,
    }
    config.validate = {
        convert: true,
        // validateRoot: false,
    };
    config.view = {
        mapping: {
            '.html': 'nunjucks',
        },
        root: [
            path.join(appInfo.baseDir, 'app/view'),
        ].join(',')
    };
    // add your user config here
    const userConfig = {
        // myAppName: 'egg',
    };
    config.sequelize = {
        dialect: 'mysql',
        host: '127.0.0.1',
        // 端口号
        port: '3306',
        // 用户名
        username: 'test1',
        username: 'root',

        // 密码
        password: '123456',
        password: '',
        // 数据库名
        database: 'test1',
        database: 'test',
    }
    // config.sequelize = {
    //     dialect: 'mysql',
    //     host: '127.0.0.1',
    //     // 端口号
    //     port: '3306',
    //     // 用户名
    // username: 'root',
    // // 密码
    // password: '',
    // // 数据库名
    // database: 'test',
    // }

    return {
        ...config,
        ...userConfig,
    };
};